// components/vertify.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    inputLength: {
      type: Number,
      value: 3
    },
    danwei: {
      type: String,
      value: '公里'
    },
    inputUp: {
      type: Boolean,
      value: false
    },
    inputFocus: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    currentValue: '',
    curIndex: 1
  },

  /**
   * 组件的方法列表
   */
  methods: {
    focusInput: function (e) {
      var that = this
      that.setData({
        inputFocus: true,
        bottom: e.detail.height
      })
      console.log(this.data.inputUp)
    },
    getFocus (e) {
      let that = this
      that.triggerEvent('getHeight', e.detail.height)
    },
    blur () {
      let that = this
      that.triggerEvent('getHeight', 0)
    },
    complete: function () {
      var that = this
      that.setData({
        inputFocus: false
      })
    },
    clearCurrentValue() {
      this.setData({
        currentValue: ''
      })
    },
    setCurrentValue: function (e) {
      var that = this
      let currentValue = e.detail.value
      let curIndex = e.detail.value.length
      that.setData({
        currentValue,
        curIndex
      })
      if (currentValue.length <= that.data.inputLength) {
        that.triggerEvent('change', currentValue)
      } else {
        that.complete()
        return
      }
    }
  }
})
